//
//  ScrollViewDelegate.m
//  States and Capitals
//
//  Created by Ward Fred on 11/8/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "ScrollViewDelegate.h"
#import "TouchScrollView.h"


@implementation ScrollViewDelegate


-(UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView {
    return [[scrollView subviews] objectAtIndex:0];
}
- (void)scrollViewDidScroll:(UIScrollView *)sender;
{
	UILabel *label = ((TouchScrollView *)sender).quizLabel; 
	if(sender.frame.size.height > sender.frame.size.width)//portrait
		label.frame = CGRectMake(sender.contentOffset.x, [UIScreen mainScreen].applicationFrame.size.height - label.bounds.size.height+sender.contentOffset.y, label.bounds.size.width, label.bounds.size.height);
	else//landscape
		label.frame = CGRectMake(sender.contentOffset.x, [UIScreen mainScreen].applicationFrame.size.width - label.bounds.size.height+sender.contentOffset.y, label.bounds.size.width, label.bounds.size.height);
	//NSLog(@"label rect after scrolling: %@", NSStringFromCGRect(label.frame));
	
	//NSLog(@"quizlabel %@", NSStringFromCGRect(label.frame));

	//NSLog(@"co: %f, %f",sender.contentOffset.x, sender.contentOffset.y);
	[label setNeedsLayout];	
	UIButton *button = ((TouchScrollView *)sender).backButton;
	button.frame = CGRectMake(sender.contentOffset.x, sender.contentOffset.y, button.bounds.size.width, button.bounds.size.height);
	[button setNeedsLayout];
}


- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{

}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    
}

@end
